<?php
class App_Page_Service_Layout
{
	/**
	 * @var App_Page_Model_Layout
	 */
	protected $_modelLayout;
	
	/**
	 * @return void
	 */
	public function __construct() 
	{
		$this->_modelLayout = Main_Model::factory('Page_Model_Layout');	
	}
	
	/**
	 * @var App_Page_Model_Layout
	 */
	public function getModelLayout()
	{
		return $this->_modelLayout;
	}
	
	/**
	 * @param array $data
	 * @return bool
	 */
	public function insertItem($data)
	{
		$langId = Zend_Registry::getInstance()->langId;
		$data += array('lang_id' => $langId);
		return $this->_modelLayout->insertItem($data);
	}
	
	/**
	 * @param array $data
	 * @param int $layoutId
	 * @return bool
	 */
	public function updateItem($data, $layoutId)
	{
		$langId = Zend_Registry::getInstance()->langId;
		$data += array('lang_id' => $langId);
		return $this->_modelLayout->updateItem($data, $layoutId);
	}
	
	/**
	 * @param int $id
	 * @return array
	 */
	public function getItemById($id) 
	{
		$langId = Zend_Registry::getInstance()->langId;
		return $this->_modelLayout->getItemById($id, $langId);
	}
	
	/**
	 * @param string $name
	 * @return array
	 */
	public function getItemByName($name) 
	{
		$langId = Zend_Registry::getInstance()->langId;
		return $this->_modelLayout->getItemByName($name, $langId);
	}
	
	/**
     * @param string $value 
     * @param null $otherCond 
     * @return bool
     */
    public function checkUnique ($value, $otherCond = null)
    {
        $list = $this->getItemByName($value);
        return empty($list) ? true : false;
    }
	
	/**
	 * @param int $id
	 * @return bool
	 */
	public function deleteItem($id) 
	{
		return $this->_modelLayout->deleteItem($id);
	}
	
	/**
	 * @return array
	 */
	public function getAllIdAndName() 
	{
		$langId = Zend_Registry::getInstance()->langId;
		return $this->_modelLayout->getAllIdAndName($langId);
	}
	
	
}
?>